(function() {

	angular.module('e-shop').directive('navbar', ['$timeout', "$window", function($timeout, $window,EVENT) {
		return {
			restrict: 'AE',
			templateUrl:'app/navbar/navbar.html',
			replace:true,
			controller:navbarCtroller,
			controllerAs:'navbar'
		}
	}])
	

    navbarCtroller.$inject = ['$scope', 'Api','$uibModal', '$state','assetUrl'];

    function navbarCtroller($scope, API,$uibModal, $state,assetUrl) {
        var vm = this;

        vm.logo = assetUrl+'assets/images/logo-pic.png';

        vm.exit = function logout() {
            API.Login.Out().$promise.then(function(data) {
            		vm.InfoModel('sm','退出成功','success')
                    $state.go('login');
            })
        }
        vm.InfoModel = function openModel(size, info,type,callback) {
				var modalInstance = $uibModal.open({
					animation: true,
					templateUrl: 'InfoModel',
					controller: 'InfoModelCtrl',
					size: size,
					resolve: {
						info: function() {
							return info;
						},
						type:function(){
							return type;
						}
					}
				});

				modalInstance.result.then(callback);
		}
    }
	
})();

